local InnerDataManagerFL = require("innerdata.InnerDataManagerFL")
local InnerDataDefine = require("innerdata.Define")

ServerOpenTime = ServerOpenTime or 0

function W2LProcess(human, type, nData)
    if nData.type == 1 then
          ServerOpenTime = nData.data.serverOpenTime
    end
end


function getHadOpenDay()            --得到已开服多少天
  local HAD_OPEN_DAY = 1
  if not ServerOpenTime or ServerOpenTime == 0 then
    return HAD_OPEN_DAY
  end
  local nTimeStamp = os.time()
  local nToday = os.date("%Y%m%d", nTimeStamp)
  local nServerOpenDay = os.date("%Y%m%d", ServerOpenTime)
  if nServerOpenDay > nToday then
    HAD_OPEN_DAY = 1
  else
    local nServerOpenTime = ServerOpenTime
    local nServerOpenDateTime = os.date("*t", nServerOpenTime)
    nServerOpenDateTime.hour = 0
    nServerOpenDateTime.min = 0
    nServerOpenDateTime.sec = 0

    local nTodayDateTime = os.date("*t", nTimeStamp)
    nTodayDateTime.hour = 0
    nTodayDateTime.min = 0
    nTodayDateTime.sec = 0
    local nTimeDiff = os.time(nTodayDateTime) - os.time(nServerOpenDateTime)
    HAD_OPEN_DAY =  math.ceil(nTimeDiff / 86400) + 1
  end
  return HAD_OPEN_DAY
end


InnerDataManagerFL.Register(InnerDataDefine.INNERDATA_TYPE_SERVERCOMMON, W2LProcess)
